<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCompanyUserPivotTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('company_user_pivot', function (Blueprint $table) {
            $table->unsignedInteger('company_id')->index()->comment('公司ID');
            $table->unsignedInteger('user_id')->index()->comment('用户ID');
            $table->timestamp('hiredate_at')->comment('入职时间');
            $table->boolean('fingerprint')->default(false)->comment('是否录入指纹');
            $table->boolean('transaction')->default(false)->comment('是否办理保安证');
            $table->string('dormitory')->nullable()->comment('宿舍地址');
            $table->date('expiry')->nullable()->comment('合同到期日期');
            $table->timestamp('departure_at')->nullable()->comment('离职时间');
            $table->unsignedInteger('score')->nullable()->comment('评分');
            $table->string('comment')->nullable()->comment('评价');
            $table->primary(['company_id', 'user_id', 'hiredate_at']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('company_user_pivot');
    }
}
